﻿// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- 
// XMLocalizator 0.9
// This code is under The MIT Licence (http://xmlocalizator.codeplex.com/license).
// Copyright (c) 2011 Bartosz Lenar (http://bartoszlenar.com/).
//
// For the full list of people involved in this project, visit:
// http://xmlocalizator.codeplex.com/wikipage?title=About
//
// The latest release, documentation, examples and demo applications always available on:
// http://xmlocalizator.codeplex.com/
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- 

using System;
using System.Text;
using System.Xml.Serialization;

namespace XMLocalizator.XmlElements
{

    /// <summary>
    /// The core XML element, representing a single phrase.
    /// </summary>
    [XmlRoot("Phrase")]
    public sealed class Phrase : IComparable<Phrase>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Phrase"/> class.
        /// </summary>
        public Phrase()
        { 
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Phrase"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="Key">The key.</param>
        /// <param name="Value">The value.</param>
        public Phrase(int id, String key, String value)
        {
            Id = id;
            Key = key;
            Value = value;
        }

        /// <summary>
        /// Gets or sets the id of this phrase.
        /// </summary>
        /// <value>
        /// The id of this phrase.
        /// </value>
        [XmlAttribute]
        public int Id { get; set; }

        /// <summary>
        /// Gets or sets the key value of this phrase.
        /// </summary>
        /// <value>
        /// The key value of this phrase.
        /// </value>
        [XmlAttribute]
        public String Key { get; set; }

        /// <summary>
        /// Gets or sets the value of this phrase.
        /// </summary>
        /// <value>
        /// The value of this phrase.
        /// </value>
        [XmlText]
        public String Value { get; set; }

        /// <summary>
        /// Compares to.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns></returns>
        public int CompareTo(Phrase other)
        {
            return Key.CompareTo(other.Key);
        }
       
    }
}
